/*******************************************************************
//  Inverse Constellation mapping 
//   16 QAM
//   0 <= x < 2 && 0<= y < 2 -> 0000    0<= x < 2 && 2<= y -> 0001
//   2 <= x && 0<= y < 2 -> 0010        2<= x &&  2<= y -> 0011 
//   0 <= x < 2 && -2 <= y < 0 -> 0100  0<= x < 2 && y < -2 -> 0101 
//   2 <= x && -2<= y < 0 -> 0110       2<= x && y < -2 -> 0111 
//   -2 <= x < 0 && o <= y < 2 -> 1000  -2<= x < 0 && 2 <= y -> 1001 
//   x < -2 && 0<= y < 2 -> 1010        x < -2 && 2 <= y -> 1011 
//   -2 <= x < 0 && -2 <= y < 0 -> 1100 -2<= x < 0 && y < -2 -> 1101 
//   x < -2 && -2 <= y < 0 -> 1110      x < -2 && y < -2 - > 1111 
//  Date : 04/11/2011
//  Jungmin Park
********************************************************************/

#include "inverse_constellation_mapping.h"

void inverse_constellation_mapping (char *a, float x, float y)
{
	if  (0 <= x && x < 2 && 0<= y && y < 2) *a = 0x00;
	else if (0<= x && x < 2 && 2<= y ) *a = 0x1;
	else if (2 <= x && 0<= y && y < 2) *a = 0x02;
	else if (2<= x &&  2<= y) *a = 0x03;
	else if (0 <= x && x < 2 && -2 <= y && y < 0) *a = 0x04;
	else if (0<= x && x < 2 && y < -2) *a = 0x05;
	else if (2 <= x && -2<= y && y < 0) *a = 0x06;
	else if (2<= x && y < -2) *a = 0x07;
	else if (-2 <= x && x < 0 && 0 <= y && y < 2) *a = 0x08;
	else if (-2<= x && x < 0 && 2 <= y) *a = 0x09;
	else if (x < -2 && 0<= y && y < 2) *a = 0x0a;
	else if (x < -2 && 2 <= y) *a = 0x0b;
	else if (-2 <= x && x < 0 && -2 <= y && y < 0) *a = 0x0c;
	else if (-2<= x && x < 0 && y < -2) *a = 0x0d;
	else if (x < -2 && -2 <= y && y < 0) *a = 0x0e;
	else if (x < -2 && y < -2) *a = 0x0f;
	else *a = 0x00;
}


